<?php

namespace App\Http\Controllers\Source\Rong360;

use App\Facades\CommonPlatformRequestFacade;
use App\Jobs\NotifyBindCardStatus;
use App\Library\Guzzle\Sign;
use App\Library\Source\Rong360\Rong360Request;
use App\Models\UserBankCard;
use Illuminate\Http\Request;
use App\Http\Controllers\Source\BaseController;
use Key\Rong360;
use Service\User;

class Rong360Controller extends BaseController
{
    use User;
    /**
     * @throws \Exception
     * @author luwei
     * @date 2019-02-22 14:08
     */
    public function index(Request $request){
        $data = ['123'];
        try{
            $data = $request->data;
            $data = $this->userBankList(5);
            $returnData = [
                'order_no' => '1',
                'bank_card_list' => $data
            ];
            return r360Success('',[
                'data' => $returnData
            ]);

        }catch (\Exception $e){
            throw new \Exception($e->getMessage());
        }
    }

    public function fixR360Check(){
        $list = \App\Models\User::whereNull('r360_check')->with(['validCert'])->limit(10)->get();
        /**
         * @var $user \App\Models\User
         */
        foreach ($list as $user){
            if($user->validCert){
                $user->r360_check = strtoupper(md5($user->phone_num . strtoupper($user->validCert->num)));
                $user->save();
            }
        }
    }


}
